ceTe Software Help Library for Java September - 2021
DynamicPDF Generator for Java / Programming with Generator for Java / Fonts And Text / TrueType Collections
In This Topic
    TrueType Collections
    In This Topic

    A TrueType Collection (TTC) is a collection of TrueType fonts combined into a single file structure. In TrueType Collections the common glyphs are shared among the fonts present in the collection and reduces file space. DynamicPDF accesses TTC fonts using an index or font name. For example, if a TTC contains four TrueType fonts, then each font's index is determined by its location in the TTC, beginning with zero index value.

    The following examples illustrate using a TTC by specifying index and a TTC by specifying font name.

    TTC Specifying Index

    [Java]
    //Create a TextArea
    TextArea area = new TextArea("Hello TTC Testing", 100, 100, 100, 100);
    
    //Create a open type font collection.
    OpenTypeFontCollection collection = new OpenTypeFontCollection("[fontCollectionPath]/font.ttc");
                    
    //Assign opentype font to label from Collection using the Index
    area.setFont(collection.getFont(1));
    

    TTC Specifying Font Name

    [Java]
    //Create a open type font collection.
    OpenTypeFontCollection collection = new OpenTypeFontCollection("[fontCollectionPath]/font.ttc");
    
    //Gets all font names present in the TTC
    String[] fontNames = collection.getFontNames();
    
    //Getting Font from collection using font name.
    OpenTypeFont font = collection.getFont(fontNames[0]);